package com.jlt.service.sys;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.jlt.dao.sys.MenuDao;
import com.jlt.entity.sys.Menu;

/**
 * 菜单相关实体的管理类,.
 * 
 * @author zhoutao
 */
//Spring Bean的标识.
@Component
//默认将类中的所有函数纳入事务管理.
@Transactional
public class MenuManager {

	private static Logger logger = LoggerFactory.getLogger(MenuManager.class);

	private MenuDao menuDao;

	/**
	 * @param id
	 * @return 菜单实体
	 */
	@Transactional(readOnly = true)
	public Menu getMenu(Long id) {
		return menuDao.get(id);
	}
	
	/**
	 * 加载子菜单
	 * @param 父菜单id
	 * @return 菜单list
	 * @author zhoutao
	 */
	@Transactional(readOnly = true)
	public List<Menu> loadChildMenus(Long parentId) {
		logger.info("load child menus");
		return menuDao.loadChildMenus(parentId);
	}
	
	@Autowired
	public void setMenu(MenuDao menuDao) {
		this.menuDao = menuDao;
	}
}
